#ifndef MYCUSTOMPLOT_H
#define MYCUSTOMPLOT_H

#include <QObject>
#include <QMouseEvent>
#include <QTouchEvent>
#include "common/qcustomplot.h"
#include <QPinchGesture>
#include <QContextMenuEvent>
#include <QMenu>
#include <QAction>
#include <QPointF>

class MyCustomPlot : public QCustomPlot
{
    Q_OBJECT
public:
    MyCustomPlot(QWidget *parent = nullptr);
    void shrinkView(double factor);
    void WheelShrinkView(QPointF Center,double factor);

protected:
//    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseDoubleClickEvent(QMouseEvent *event) override;
//    void mouseReleaseEvent(QMouseEvent *event) override;
//    void mousePressEvent(QMouseEvent *event) override;

    bool event(QEvent *event) override;

//    bool gesture

    bool handleTouchEvent(QTouchEvent *event);

    void contextMenuEvent(QContextMenuEvent *event) override;

private slots:
    void onActionTriggered1();
    void onActionTriggered2();
    void onActionTriggered3();
    void onActionTriggered4();


private:
     void handlePinchGesture(QPinchGesture *gesture) ;

     void RescaleAxes(double scaleFactor);
     void MoveView(const QPointF &translation);



     QAction* action1,* action2,* action3,* action4;
    QMenu* menu;


     double m_startDistance = 0; // 用于缩放的起始距离
     QPointF m_startCenter; // 用于移动的起始中心点

     QDateTime CollectTimePre;//上一个采集的时间

};

#endif // MYCUSTOMPLOT_H
